package com.zenithmind.article.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zenithmind.article.pojo.domain.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ArticleMapper extends BaseMapper<Article> {
    
    /**
     * 获取活跃作者统计
     * @param limit 返回数量限制
     * @return 活跃作者统计数据
     */
    @Select("SELECT user_id as userId, COUNT(*) as articleCount, SUM(view_count) as totalViews " +
            "FROM article " +
            "WHERE status = 1 " +
            "GROUP BY user_id " +
            "ORDER BY articleCount DESC, totalViews DESC " +
            "LIMIT #{limit}")
    List<Map<String, Object>> getActiveAuthors(Integer limit);
}
